package edu.ynu.e_platform.dao;

import edu.ynu.e_platform.common.dao.LogicDAO;
import edu.ynu.e_platform.entities.Business;
import edu.ynu.e_platform.entities.Shop;
import edu.ynu.e_platform.entities.ShopItem;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author manwen Yang
 */
@Component
public interface ShopItemDao extends LogicDAO<ShopItem, Long> {

    public List<ShopItem> findByItemStatus(Integer status);

    @Query(value = "select s from ShopItem s where s.itemStatus = :status")
    Page<ShopItem> find(@Param("status")Integer itemStatus, Pageable pageable);

    @Query(value = "select s from ShopItem s where s.shop = :shop and s.itemStatus = :status")
    Page<ShopItem> pageFindShopItemByShop(@Param("shop") Shop shop, @Param("status") Integer status, Pageable pageable);
}
